<?php
class Form extends htmlTag {
	protected $submitButton;
	function __construct($method='get',$id = null, $atributes = null) {
		parent::__construct('form','',$id,$atributes);
		
		if(is_null($id)){
			$id = 'form'.htmlTag::$nrTags;
		}
		$this->id=$id;
		$this->addAtribute('name',$this->id);
		
		$this->addAtribute('method',$method);
		
		$this->closeTag = TRUE;
		$this->isHead = FALSE;
		$this->submitButton = new Button('Submit','submit','submiButton');
		$this->addTag($this->submitButton, self::AFTER_CONTENT);
	}
	public function setMethod($method){
		$this->addAtribute('method',$method);
	}
	public function setSubmitLabel($newLabel){
		$this->submitButton->addAtribute('value',$newLabel);
	}
	
	
}
class Button extends htmlTag{
	/**
	 * Bild a form Button
	 * @param unknown_type $value
	 * @param unknown_type $type
	 * @param unknown_type $id
	 * @param unknown_type $atributes
	 */
	public function __construct($value='Submit',$type='button',$id=null,$atributes = null){
		parent::__construct('input','',$id,$atributes);
		if(is_null($id)){
			$id = 'button'.htmlTag::$nrTags;
		}
		$this->id=$id;
		$this->closeTag = FALSE;
		$this->isHead = FALSE;
		$this->addAtribute('type',htmlentities(strtolower($type)));
		$this->addAtribute('name',$this->id);
		$this->addAtribute('value',$value);
		
	}
	
}
class FormInput extends htmlTag{
	
public function __construct($type='text',$value='Input here',$id=null,$atributes = null){
		parent::__construct('input','',$id,$atributes);
		if(is_null($id)){
			$id = 'input'.htmlTag::$nrTags;
		}
		$this->id=$id;
		$this->closeTag = FALSE;
		$this->isHead = FALSE;
		$this->addAtribute('type',htmlentities(strtolower($type)));
		$this->addAtribute('name',$this->id);
		$this->addAtribute('value',$value);
	}
}